import currency from 'currency.js';

export const money = (
    value,
    args = {
        symbol: '¥'
    }
) => {
    return currency(value, args);
};

export const number = (
    value,
    args = {
        symbol: '',
        separator: '',
        precision: 2,
        fromCents: false
    }
) => {
    return currency(value, {
        symbol: '',
        separator: '',
        precision: 2,
        fromCents: false,
        ...args
    });
};
export const distance = (value, args = {}) => {
    if (value > 500)
        return currency(value, {
            symbol: value >= 500 ? 'km' : 'm',
            separator: '',
            precision: 2,
            pattern: `#!`,
            fromCents: false,
            ...args
        }).divide(1000);
    else
        return currency(value, {
            symbol: value >= 500 ? 'km' : 'm',
            separator: '',
            precision: 0,
            pattern: `#!`,
            fromCents: false,
            ...args
        });
};
